/* import Store from '../store/index.js'
import Util from './util.js' */
/* 地址主要用于登录、注册、修改信息、图片上传、语音上传等 */
//应用网络访问地址
const serverUrl = 'https://qq.wyx2013.cn'
//应用模块地址（二级目录）如果是public请填写‘/public/’
const moduleUrl = '/'

// 管理账号信息
const USERS_KEY = 'USERS_KEY';

var page = 1,
	id = 4; // 定义全局参数,控制数据加载  
// 定义一个混入对象
var myMixin = {
	data: function() {
		return {
			serverUrl: serverUrl
		}
	},
	methods: {
		login() {
			var that = this;
			var ret = {
				status: false,
				msg: "登录失败"
			}
			uni.request({
				url: that.app.apiHost + "?m=login&a=logout&ajax=1",
				data: {
					"authcode": that.app.getAuthCode(),
					"fromapp": that.app.fromapp()
				},
				success: function(res) {
					that.$store.commit('login', res); //保存到vuex
					uni.setStorage({ //缓存用户登陆状态
						key: USERS_KEY,
						data: res
					})
					that.$util.goTo(this.$store.state.pages.user.home) //跳转到个人中心页面
				}
			})
			return ret;
		},
		logout(e) {
			var that = this;
			uni.request({
				url: that.app.apiHost + "?m=login&a=logout&ajax=1",
				data: {
					"authcode": that.app.getAuthCode(),
					"fromapp": that.app.fromapp()
				},
				success: function(res) {
					that.$store.commit('logout');
					uni.removeStorage({
						key: USERS_KEY
					})
					that.$util.goTo(that.$store.state.pages.home.path) //跳转到首页页面
				}
			})
		},
		/* 预览照片 */
		previewImage(e, imageList) { //@click="previewImage($event,['https://iode.jpg'])" data-index="0">
			let index = e.currentTarget.dataset.index;
			/* let list = imageList.map((item, index) => {
				return item.url;
			}); */
			uni.previewImage({
				current: imageList[index], // 当前显示图片的http链接   
				urls: imageList //要预览的图片列表
			});
		},
		goTo(e) {
			var url = e.currentTarget.dataset.path;
			this.$util.goTo(url);
		}
	},
	onReachBottom() {
		if (id > 6) {
			this.listData.loadStatus = "noMore"
		} else {
			this.listData.loadStatus = "loading";
			this.listData.list.push.apply(this.listData.list, [{
				id: id
			}])
		}
		id++;
	}
}

export default myMixin
